<?php
/**
 * Created by PhpStorm.
 * User: 张梦华
 * Date: 2021/5/17
 * Time: 9:37
 */

namespace Modules\Chinadmin\Http\Requests;


use Illuminate\Foundation\Http\FormRequest;

/**
 * 案件验证类
 * Class CasesRequest
 * @package Modules\Chinadmin\Http\Requests
 */
class CasesRequest extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'service_type'=>'required',
            'cases_type'=>'required',
            'owmer_phone'=>'required',
            'region' => 'required',
            'address' => 'required',
            'repair_address' => 'required',
            'time' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'service_type.required'=>'服务类型必须填写',
            'cases_type.required'=>'案件类型必须填写',
            'owmer_phone.required'=>'车主电话必须填写',
        ];
    }

    /**
     * 配置验证器实例.
     *
     * @param  \Illuminate\Validation\Validator  $validator
     * @return void
     */
    /*public function withValidator($validator)
    {
        $validator->after(function ($validator) {

            //print_r($validator->errors());exit;

            if ($this->somethingElseIsInvalid()) {
                $validator->errors()->add('field', 'Something is wrong with this field!');
            }
        });
    }*/

//    protected function prepareForValidation()
//    {
//
//    }

}